﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace zakalib
{
    internal static class NativeZaka
    {
        private const string DLL_NAME = "zaka.dll";

        #region 日志
        /// <summary>
        /// debug
        /// </summary>
        /// <param name="content"></param>
        [DllImport(DLL_NAME)]
        internal static extern void debug(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        [DllImport(DLL_NAME)]
        internal static extern void info(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        [DllImport(DLL_NAME)]
        internal static extern void error(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        [DllImport(DLL_NAME)]
        internal static extern void success(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        [DllImport(DLL_NAME)]
        internal static extern void exception(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        [DllImport(DLL_NAME)]
        internal static extern void custom(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string folder,
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        #endregion

        [DllImport(DLL_NAME)]
        internal static extern void test_receive_int(int text);
        [DllImport(DLL_NAME)]
        internal static extern int test_return_int();

        [DllImport(DLL_NAME)]
        //internal static extern void test_receive_string(IntPtr content);
        internal static extern void test_receive_string(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content
            );
        [DllImport(DLL_NAME)]
        internal static extern IntPtr test_return_string();
        [DllImport(DLL_NAME)]
        internal static extern void test_receive_struct(
            [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
            string content);
        [DllImport(DLL_NAME)]
        internal static extern void test_receive_bytes(byte[] array);



        [DllImport(DLL_NAME)]
        internal static extern IntPtr get_html(IntPtr url);
    }

    //[StructLayout(LayoutKind.Sequential)]
    //public struct test_struct
    //{
    //    public int user_age;
    //    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
    //    //[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]
    //    public string user_name;
    //}
}
